<?php
defined('BASEPATH') OR exit('No direct script access allowed');


class Suggestion extends CI_Controller
{

	public function __construct()
	{
		parent::__construct();
		$this->load->model('Suggestion_Model');
		$this->load->helper('url_helper');
	}
	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 *        http://example.com/index.php/welcome
	 *    - or -
	 *        http://example.com/index.php/welcome/index
	 *    - or -
	 * Since this controller is set as the default controller in
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see https://codeigniter.com/user_guide/general/urls.html
	 */
//	public function show($page)
//	{
//		$data=array('title'=>'法院介绍');
//		$this->load->view('head_sec',$data);
//		$this->load->view($page);
//		$this->load->view('foot_sec',$data);
//	}

	public function new_suggestion(){
		$articles=array('title'=>'新建建议');
		$this->load->view('head_sec',$articles);
		$this->load->view('new_suggestion',$articles);
		$this->load->view('foot_sec',$articles);
	}

	public function save(){
		$data=array();
		if(isset($_POST['title'])){
			$data['title']=$_POST['title'];
		}
		if(isset($_POST['username'])){
			$data['username']=$_POST['username'];
		}
		if(isset($_POST['mobile'])){
			$data['mobile']=$_POST['mobile'];
		}
		if(isset($_POST['content'])){
			$data['content']=$_POST['content'];
		}
		$data['gmt_create']=date("Y-m-d H:i:s" ,time());
		$data['gmt_modify']=date("Y-m-d H:i:s" ,time());
		$data['is_deleted']='N';

		$result=$this->Suggestion_Model->add_suggestion($data);
		if($result){
			$articles=array("title"=>"创建建议成功");
			$this->load->view('head_sec',$articles);
			$this->load->view('suggestion_success',$articles);
			$this->load->view('foot_sec',$articles);
		}else{
			$this->load->view('errors/html/error_404');
		}
	}

}


